package com.jingyuan.common.entity.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class PropertyReadUtil {
    private Properties properties;

    public PropertyReadUtil(String filepath) {
        // 使用ClassLoader加载properties配置文件生成对应的输入流
        InputStream in = PropertyReadUtil.class.getClassLoader().getResourceAsStream(filepath);
        // 使用properties对象加载输入流
        properties=new Properties();
        if(in==null){
            System.out.println("失败");
        }
        try {
            properties.load(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public String getProperty(String key) {
        //in获取key对应的value值
        return properties.getProperty(key);
    }


}
